﻿@inject IStringLocalizer<BootstrapBlazor.Shared.Samples.SearchDialogs> Localizer
@inject DialogService DialogService

<Button Text="@Localizer["SearchDialogsNormalButtonText"]" OnClickWithoutRender="@ShowDialog" />

<ConsoleLogger @ref="Logger" class="mt-3" />

@code {
    [NotNull]
    private ConsoleLogger? Logger { get; set; }

    private async Task ShowDialog()
    {
        var option = new SearchDialogOption<Foo>()
        {
            Title = "search popup",
            Model = new Foo(),
            ItemsPerRow = 2,
            RowType = RowType.Inline,
            OnCloseAsync = () =>
            {
                Logger.Log("Close button is clicked");
                return Task.CompletedTask;
            },
            OnResetSearchClick = () =>
            {
                Logger.Log("Reset button is clicked");
                return Task.CompletedTask;
            },
            OnSearchClick = () =>
            {
                Logger.Log("Search button is clicked");
                return Task.CompletedTask;
            }
        };

        await DialogService.ShowSearchDialog(option);
    }
}
